package emb 
{
	import flash.display.*;
	/**
	 * ...
	 * @author Excel Excel
	 */
	public class ETiler implements ITiler
	{
		[Embed(source = "../../assets/YELLOW64.PNG")]
		[Bindable]
		public var img1:Class;
		[Embed(source = "../../assets/PATCH64.PNG")]
		[Bindable]
		public var img2:Class;
		[Embed(source = "../../assets/ROCKS64.PNG")]
		[Bindable]
		public var img3:Class;
		[Embed(source = "../../assets/MARBLE64.PNG")]
		[Bindable]
		public var img4:Class;
		[Embed(source = "../../assets/wall64.PNG")]
		[Bindable]
		public var img5:Class;
		
		[Embed(source = "../../assets/rocks2_64.PNG")]
		[Bindable]
		public var imgr2:Class;
		private var imgr2B:Bitmap;
		[Embed(source = "../../assets/rocks3_64.PNG")]
		[Bindable]
		public var imgr3:Class;
		private var imgr3B:Bitmap;
		[Embed(source = "../../assets/rocks4_64.PNG")]
		[Bindable]
		public var imgr4:Class;
		private var imgr4B:Bitmap;
		
		
		private var bmp:Object;
		
		
		public function ETiler() 
		{
			//Dummy
			bmp = new Object();
			imgr2B = new imgr2() as Bitmap;
			imgr3B = new imgr3() as Bitmap;
			imgr4B = new imgr4() as Bitmap;
			bmp[0xFFF200] = new img1() as Bitmap;
			bmp[0xFF7F27] = new img2() as Bitmap;
			bmp[0x99D9EA] = new img3() as Bitmap;
			bmp[0xB97A57] = new img4() as Bitmap;
			bmp[0x000000] = new img5() as Bitmap;
		}
		
		public function rand(seed:uint):uint
		{

			return (seed * 43691 + 911) % 65537;
		}
		
		public function getTile(color:uint, seed:uint = 0):BitmapData
		{
			//Want variety
			if (color == 0x99D9EA)
			{
				switch (rand(seed)%6)
				{
					case 0:
						return imgr4B.bitmapData;
					case 1:
						return imgr2B.bitmapData;
					case 2:
						return imgr3B.bitmapData;
					default:
						return bmp[color].bitmapData;
				}
			}
			else
			return bmp[color].bitmapData;
		}
	}

}